<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>日志管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
 <link rel="stylesheet" href="${ctx}/resources/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<link rel="stylesheet" type="text/css" href="${ctx}/resources/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/resources/css/wu.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/resources/css/icon.css" />
<script type="text/javascript" src="${ctx}/resources/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/resources/zTree/js/jquery.ztree.core.js"></script>

  </head>
  <body>
  <div class="easyui-panel" data-options="title:'查询条件',iconCls:'icon-search'" style="width:100%;">
		<form id="searchFrm" method="get">
			<table width="100%" cellpadding="10" >
				<tr>
					<td width="50%"> 
					<input class="easyui-textbox" name="loginname"
							data-options="label:'用户姓名:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
					<td width="50%">
					<input class="easyui-textbox" name="loginip"
							data-options="label:'用户地址:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
				</tr>
				<tr>
					<td width="50%">
					<input class="easyui-textbox" name="startDate"
							data-options="label:'开始日期:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
					<td width="50%">
					<input class="easyui-textbox" name="endDate"
							data-options="label:'结束日期:',labelPosition:'left',labelAlign:'right'"
							style="width:80%;">
					</td>
				</tr>
				<tr>
					<td colspan="3" align="center">
						<a href="javascript:void(0)" class="easyui-linkbutton" onclick="doSearch()" data-options="iconCls:'icon-search'">查询</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#searchFrm').form('clear')" data-options="iconCls:'icon-reload'">重置</a>
						
					</td>
				</tr>
			</table>
		</form>
	</div>
	

	
	
<!-- 查询条件结束 -->
	 <div style="height: 2px"></div>
	 <!-- 数据表格开始 -->
    <table id="table" class="easyui-datagrid" data-option="multiple:true"  style="width:100%;">
    </table>
    
	<div id="tb">

	<a href="javascript:void(0)" class="easyui-linkbutton" id="deleteUser" data-options="iconCls:'icon-remove',plain:true">删除用户</a>
	<a href="javascript:void(0)" class="easyui-linkbutton" id="deleteUsers" data-options="iconCls:'icon-remove',plain:true">批量删除用户</a>
	</div>
	
	
	<!-- 添加和修改用户的弹出层 结束-->
	<script type="text/javascript">
	$("#table").datagrid({
		title:'用户列表',
	//	singleSelect:true,
		collapsible:true,
        fitColumns:true,
        pagination:true,
      /*   pagePosition:'both', */
       /*  pageSize:5,
        pageList:[5,10,15,20], */
        rownumbers:true,
        toolbar:'#tb',               //添加，修改和删除的标签
        url:'${ctx}/logInfo/loadAllLogInfo.action',
       // method:'get',
        columns:[[
                  {field:'ck',checkbox:true},
                  {field:'id',title:'ID',align:'center',width:100},
                  {field:'loginname',title:'用户姓名',align:'center',width:100},
                  {field:'loginip',title:'用户地址',align:'center',width:100},
                  {field:'logintime',title:'登陆日期',align:'center',width:100},
              ]],
	});
	
		//查询
		function doSearch(){
			var params=$("#searchFrm").serialize();
			alert(params);
			$("#table").datagrid({           //Query data with some parameters.利用参数查询
				url:'${ctx}/logInfo/loadAllLogInfo.action?'+params
			});
		};
		 
		
		//删除用户
		$("#deleteUser").click(function(){
			//得到当前行
			var row=$("#table").datagrid('getSelected');
			if(row){
				$.messager.confirm('提示','你确定要删除'+row.name+'这个用户吗?',function(r){
                    if (r){
                        $.post("${ctx}/logInfo/deleteLoginInfo.action",{id:row.id},function(result){
                                $.messager.show({    
                                    title: '提示',
                                    msg: '删除成功'
                                });
                                $("#table").datagrid("reload");//刷新表格
                        },'json');
                    }
                });
			}else{
				$.messager.show({
					title:'提示',
					msg:'请选中操作行'
				});
			}
		});	
	
		//批量删除用户
		$("#deleteUsers").click(function(){
			//得到当前行
			var rowsd=$("#table").datagrid('getSelections');
			if(rowsd){
				alert(rowsd);
				$.messager.confirm('提示','你确定要删除选择的用户吗?',function(r){
                    	var ids=[];            //定义数组接收所有选中行
                    if (r){
                    	for (var i = 0;i<rowsd.length; i++) {
                    		var newid=rowsd[i].id;    //取出列表中单个id
                    		ids.push(newid);           //将每个id放入数组ids[]
                    	} 
                    	//获取自定义table 的中的checkbox值               var id=selRow[i].OTRECORDID;   //OTRECORDID这个是你要在列表中取的单个id           ids.push(id); //然后把单个id循环放到ids的数组中  
                    	alert(ids);
                        /* $.post('${ctx}/logInfo/deleteLoginInfos.action',{ids:ids},function(result){
                                $.messager.show({    
                                    title: '提示',
                                    msg: '删除成功'
                                });
                                $("#table").datagrid("reload");//刷新表格
                        },'json'); */
                        $.ajax({
                        	url:'${ctx}/logInfo/deleteLoginInfos.action',
                        	type:'post',
                        	data:{"ids":ids},
                        	
                        	traditional:true,
                        	success:function(data){
                        		$.messager.show({    
                                    title: '提示',
                                    msg: '删除成功'
                                });
                        		 $("#table").datagrid("reload");//刷新表格
                        		},
                        	error:function(error){
                        			alert(error);
                        		},
                        });
                    }
                });
			}else{
				$.messager.show({
					title:'提示',
					msg:'请选中操作行'
				});
			}
		});	
	
	
	</script>
    
  </body>
</html>
